﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Public.Common;
using Public;

public partial class show : System.Web.UI.Page
{
   public Forum.Entities.forum_bodyinfo model = null;
   public Forum.Entities.forum_muluinfo model_mulu = null;
    public string daohang = "";
    public string rhtml = "";
    public int page = 1;
    public int id = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            id = MRequest.GetQueryInt("id", 0);
            int count = MRequest.GetQueryInt("count", 0);
            page = MRequest.GetQueryInt("page", 1);
            ShowData(id, page, count);
        }
    }
    protected void ShowData(int id, int page, int count)
    {
        if (id != 0)
        {
            model = WebBase.CacheRepository.forum_body.GetByBodyId(id);
            if (model != null)
            {
                model_mulu = WebBase.CacheRepository.forum_mulu.GetByMuLuId(model.Body_MuLuID.Value);//.GetModelByMuLuID(model.Forum_Body.Body_MuLuID);// Forum.Web.Main.Forum_MuLu.GetModel(model.Forum_Body.Body_MuLuID, null);
                daohang = " > <a href='/article-id" + model_mulu.MuLu_ID + ".aspx' title='" + model_mulu.MuLu_Name + "'>" + model_mulu.MuLu_Name + "</a> > " + model.Body_Name;

                //model.Body_FangWen = model.Body_FangWen == null ? 1 : model.Body_FangWen + 1;
                //WebBase.Repository.forum_body.Update(model);


                //model.Body_FangWen = 8000 + new Random().Next(100, 2000);

                Forum.Entities.forum_bodybodyinfo model_body = WebBase.CacheRepository.forum_bodybody.GetByBodyBodyId(id);
                string[] imglist_par = model_body.BodyBody_Body.Split('∪');

                int s = (page - 1) * 2 + 1;//开始
                int n = ((page - 1) * 2) + 2;//结束

                for (int i = 0; i < imglist_par.Length; i++)
                {
                    if ((i + 1) >= s && (i + 1) <= n)
                    {
                        rhtml += "<img alt='" + model.Body_Name + "' src='/" + imglist_par[i] + "' /><br><br>";
                    }
                }
                this.tuhtml.InnerHtml = rhtml;

                if (!string.IsNullOrEmpty(model.Body_Tag))
                {
                    IList<Forum.Entities.getbodytaginfo> taglist = WebBase.Repository.getbodytag.GetPaged("TagsRelation_BodyID=" + model.Body_ID);
                    if (taglist.Count > 0)
                    {
                        string txt_tag = "标签：";
                        for (int i = 0; i < taglist.Count; i++)
                        {
                            txt_tag += string.Format(" <a href='/tags-tagid{0}.aspx' target=_blank>{1}</a>", taglist[i].Tag_ID, taglist[i].Tag_Name);
                        }
                        this.tag.InnerHtml = txt_tag;
                    }
                }

                //hb.pagelist.info_pagelist page_ = new hb.pagelist.info_pagelist(imglist_par.Length, page, 4, 2, "show", null);
                //page_.StrType = "html";

                AspNetPage pp = new AspNetPage(imglist_par.Length, page, 4, 2);
                pp.URLTYPE = AspNetPageInfo.URLType.Html;

                this.pagehtml.InnerHtml = pp.GetPages();
            }
        }

    }
}